<?
include_once("../SmileLaughDetection.php");
/*
$sentences = array('RRRrrRRrrRRiiiiicccCCCCCCCccccaaarrrrdddo', 'iiiis', 'hhharry', 'potter', 
'WWWWIIIIIISSSSSSSS', 'i', 'hate', 'uuuuuu', 'oookk', 'it', 'worksss!');

foreach ($sentences as $string) {
		
	echo "Original:<br>$string<br>";
	
	if (strlen($string) > 3) {
		for ($i = 2; $i < strlen($string); $i++) {
	
			$prec2 = strtolower($string[$i - 2]);
			$prec1 = strtolower($string[$i - 1]);
			$corr = strtolower($string[$i]);
	
			if ($prec2 == $prec1 && $prec1 == $corr) 
			{
				$j = $i;
	
				while ($j < strlen($string) && $corr == strtolower($string[$j]))
					$j++;
	
				$tmp2 = substr($string, $j - 1, strlen($string));
				$tmp1 = substr($string, 0, $i - 1);
				$string = $tmp1.$tmp2;
	
			}
			
		}
	}
	
	if (strtolower($string[0]) == strtolower($string[1]))
		$string = substr($string, 1, strlen($string));
	if (strtolower($string[strlen($string) - 2]) == strtolower($string[strlen($string) - 1]))
		$string = substr($string, 0, strlen($string) - 1);
	
	echo "Modified: <br>$string<br>";
*/	
	$vowels = array('a' => 1, 'e' => 1, 'i' => 1, 'o' => 1, 'u' => 1, 'g' => 1);

	$word = "ehehehhhehhh";

	for ($i = 0; $i < strlen($word); $i++)
		if ($vowels[$word[$i]]) {
			$vocale = $word[$i];
			break;
		}

	$laugh = true;

	for ($i = 0; $i < strlen($word); $i++)
		if (!($word[$i] == 'h' || $word[$i] == $vocale))
			$laugh = false;

	echo $word;
	if ($laugh)
		echo " is a laughing";	
	else
		echo " is not a laughing";	

?>